<?php
    include("includes/connect_db.php");
    $id_host = $_POST['host'];
    $nama_tabel = $_POST['namaTabel'];
    $tabel = $_POST['tabel'];

    $i = 0;
    $rincianTabel = explode(',', $tabel);
    $jum = count($rincianTabel);
    foreach ($rincianTabel as $parTabel) {
        $i++;
    }

    $sql_lihat_host = "SELECT * FROM tb_host WHERE id_host = '$id_host'";
    $query_lihat_host = mysql_query($sql_lihat_host);
    $lihat_host = mysql_fetch_array($query_lihat_host);

    $koneksiBaru = mysql_connect($lihat_host['host'], $lihat_host['username'], $lihat_host['password']) or die("Connection Error: " . mysql_error());

    mysql_select_db($lihat_host['db'], $koneksiBaru) or die("Error conecting to db.");
?>

<table class="table table-bordered" data-name='<?php echo $nama_tabel; ?>'>
    <?php
        $sql_desc_tabel = "DESC $nama_tabel";
        $query_desc_tabel = mysql_query($sql_desc_tabel, $koneksiBaru);
        while ($desc_tabel = mysql_fetch_array($query_desc_tabel)) {
            $bantu = "";
            if ($i == 1) {
                $bantu = $desc_tabel[0];
            } else{
                $bantu = $nama_tabel.".".$desc_tabel[0];
            }
    ?>
    <tr>
        <td style="width: 10px;">
            <input class="idOutput" type="hidden" value="<?php echo $bantu; ?>">
            <input class="checkOutput" type="checkbox" style="display:none" checked="checked">
            <i class="icon-check check" style="opacity:0.2"></i>
        </td>
        <td>
            <?php echo $desc_tabel[0]; ?>
        </td>
        <td class="descOutput"></td>
    </tr>
    <?php
        }
    ?>
</table>